# !/usr/bin/env python
# -*- coding:utf-8 -*-
from bs4 import BeautifulSoup


class HtmlOperator(object):

    def __init__(self, page_source):
        self.bs = BeautifulSoup(page_source, 'html.parser')

    def get_page_title(self):
        return self.bs.find('title').text

    def get_titles(self):
        items = self.bs.find_all(attrs={'class': 'c-title'})
        return [item.text for item in items]

    def get_descriptions(self):
        descriptions = self.bs.select('[class^="content-right"]')
        return [description.text for description in descriptions]

    def get_page_num(self):
        return self.bs.find('strong').span.text

    def get_links(self):
        links = self.bs.find_all('span', {'class': 'c-color-gray'})
        return [link.text for link in links]
